property kasJustDoIt : false -- Disconnect wrong ARA connections without asking?
-- Internal/User setable globals
property kasTest : false -- Just testing the script?
-- Internal/User setable globals
property gasLinkSet : false -- Has the friend been asked for? - set to true to never ask
property gasLinkNeed : false
property kasLinkUserDft : "CasaVision" -- Defaults for linking access
property kasLinkPassDft : ""
property gasServSet : false
property gasServNeed : false
property kasServUserDft : "Synapse" -- Defaults for server access
property kasServPassDft : ""
property kasServNTDft : ""
-- Internal globals
global gasLinkUser -- Our friend on all machines
global gasLinkPass -- Our friend's password on all machines
global gasServUser -- Our friend on all machines
global gasServPass -- Our friend's password on all machines
global gasServNT -- Volume password
-- Internal globals
property kasBatchType : "RemoteBatch"
property gasOurAlias : "" -- The alias we own
property gasOurStatus : "" -- Empty, "RemoteLauncher" or "RemoteFolder"
property gasOurServer : "" -- Set to server of gasOurAlias
property gasOurZone : "" -- Set to zone of gasOurAlias
property gasOurName : "" -- Name of original alias
property gasOurVol : "" -- Name of volume alias resides on
property gasOurType : "" -- If we are a RemoteLauncher, this is our file type
property gasCopyLoc : {0, 0} -- The location of the copy window
-- Remote access stuff
property kraConnected : "connected" -- ARA osax strings
property kraProtocol : "ARAP"
property gasRemote : false -- set internally to true if volume was a RemoteAccess volume
property gasRemoteCfg : "" -- Set internally to ARA config needed for this access
property gasRemoteServer : "" -- Set internally to check if we are already connected to the correct server
property gasRemoteAlias : false --Set internally to rebuild ARA with alias instead of osax
property gasRemoteNum : "" -- Set internally to the telephone number of the remote machine
property gasRemoteUsr : "" -- Set internally to the login user for the remote machine
on run
if (kasTest) then
set gasOurAlias to ((item 1 of (list disks)) & ":") as alias
RunRemoteBatch()
else
if (gasOurStatus is "") then
ShowInitAlert()
else if (gasOurStatus is kasBatchType) then
RunRemoteBatch()
else
beep
end if
end if
end run
on open fsObjs
if (gasOurStatus is "") then
if the number of items in fsObjs is not 1 then
ShowInitAlert()
else
SetScriptAlias(item 1 of fsObjs)
end if
else if (gasOurStatus is kasBatchType) then
set wasMounted to IsVolMounted(gasOurVol)
if (RunRemoteBatch()) then
repeat with fsObj in fsObjs
try
set gasCopyLoc to ¬
(AkuaCopy fsObj located at gasCopyLoc with resuming given «class Dest»:gasOurAlias)
on error err
ShowAlert("An error (" & (err as string) & ") occured copying “" & (fsObj as string) & "”. The network may have been interrupted or a disk error may have occured")
end try
end repeat
if (not wasMounted) then ¬
PutAwayVol(gasOurVol)
end if
end if
end open
on RunRemoteBatch()
-- Get the user/password
GetFriend(false)
if (not gasServSet) then return
set mounted to false
-- Mount the remote volume
if (not gasRemote or not gasRemoteAlias) then
try
«event ÅkuNMSVm» gasOurVol ¬
given «class MSrv»:gasOurServer ¬
, «class TZon»:gasOurZone ¬
, «class USER»:gasServUser ¬
, «class PASS»:gasServPass ¬
, «class VPwd»:gasServNT
set mounted to true
on error
if (CouldBeSharing(gasOurZone, gasOurServer)) then
try
«event ÅkuNMSVm» gasOurVol ¬
given «class MSrv»:gasOurServer ¬
, «class TZon»:gasOurZone ¬
, «class USER»:gasServUser ¬
, «class PASS»:gasServPass ¬
, «class VPwd»:gasServNT
on error
if (kasServerAlerts) then
ShowMountAlert()
else
beep
end if
set mounted to false
end try
else
if (kasServerAlerts) then
ShowMountAlert()
else
beep
end if
set mounted to false
end if
end try
end if
if (mounted) then
try
-- Mount the remote volume
set sourceFolder to resolve server alias gasOurAlias ¬
as user name gasServUser with password gasServPass ¬
with volume password gasServNT
set mounted to true
on error
set mounted to false
if (kasServerAlerts) then
if (gasRemote) then
ShowRemoteAlert()
else
ShowMountAlert()
end if
else
beep
end if
end try
if (mounted) then
-- Our destination folder
set destFolder to PathToAlias(kasBatchDest)
-- Read in our list
set myBatchList to PathToAlias(kasBatchCopyList)
set myBatchText to read data from the data fork of myBatchList
-- Kill comments
set myBatchText to (collect lines of myBatchText that match ":*")